package com.xuelang.pipeline.artifact.app.nexus3v1;

import com.xuelang.pipeline.artifact.app.nexus3v1.config.Nexus3v1RestFeignConfig;
import com.xuelang.pipeline.artifact.app.nexus3v1.fallback.ComponentManagementServiceFallbackFactory;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.GetComponentResponse;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.ListComponentResponse;
import com.xuelang.pipeline.artifact.app.nexus3v1.xo.ApiResponseXO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 封装NexusOSS 3.37.3-02以上组件制品相关接口-对应Components
 *
 * @author xiwen.zxg
 * @since 2024/7/9
 */
@FeignClient(
        name = "component-service",
        url = "${feign.rpc.nexus3V1RestService}",
        configuration = Nexus3v1RestFeignConfig.class,
        fallbackFactory = ComponentManagementServiceFallbackFactory.class)
public interface ComponentManagementService {

    /**
     * 查询组件列表
     *
     * @param continuationToken
     * @param repository
     *
     * @return
     */
    @GetMapping(value = "/v1/components", produces = "application/json;charset=utf-8")
    ApiResponseXO<ListComponentResponse> componentList(
            @RequestParam(value = "continuationToken", required = false) String continuationToken,
            @RequestParam(value = "repository", required = false) String repository);

    /**
     * 上传一个组件
     *
     * @param repository
     * @return
     */
    @PostMapping(value = "/v1/components", produces = "application/json;charset=utf-8")
    ApiResponseXO<Void> uploadComponent(
            @RequestParam(value = "repository", required = false) String repository,
            @RequestParam(value = "r.asset", required = false) MultipartFile rAsset,
            @RequestParam(value = "r.asset.pathId", required = false) String rAssetPathId,
            @RequestParam(value = "pypi.asset", required = false) MultipartFile pypiAsset,
            @RequestParam(value = "helm.asset", required = false) MultipartFile helmAsset,
            @RequestParam(value = "yum.directory", required = false) String yumDirectory,
            @RequestParam(value = "yum.asset", required = false) MultipartFile yumAsset,
            @RequestParam(value = "yum.asset.filename", required = false) String yumAssetFilename,
            @RequestParam(value = "docker.asset", required = false) MultipartFile dockerAsset,
            @RequestParam(value = "rubygems.asset", required = false) MultipartFile rubygemsAsset,
            @RequestParam(value = "nuget.asset", required = false) MultipartFile nugetAsset,
            @RequestParam(value = "npm.asset", required = false) MultipartFile npmAsset,
            @RequestParam(value = "raw.directory", required = false) String rawDirectory,
            @RequestParam(value = "raw.asset1", required = false) MultipartFile rawAsset1,
            @RequestParam(value = "raw.asset1.filename", required = false) String rawAsset1Filename,
            @RequestParam(value = "raw.asset2", required = false) MultipartFile rawAsset2,
            @RequestParam(value = "raw.asset2.filename", required = false) String rawAsset2Filename,
            @RequestParam(value = "raw.asset3", required = false) MultipartFile rawAsset3,
            @RequestParam(value = "raw.asset3.filename", required = false) String rawAsset3Filename,
            @RequestParam(value = "apt.asset", required = false) MultipartFile aptAsset,
            @RequestParam(value = "maven2.groupId", required = false) String maven2GroupId,
            @RequestParam(value = "maven2.artifactId", required = false) String maven2ArtifactId,
            @RequestParam(value = "maven2.version", required = false) String maven2Version,
            @RequestParam(value = "maven2.generate-pom", required = false) Boolean maven2GeneratePom,
            @RequestParam(value = "maven2.packaging", required = false) String maven2Packaging,
            @RequestParam(value = "maven2.asset1", required = false) MultipartFile maven2Asset1,
            @RequestParam(value = "maven2.asset1.classifier", required = false) String maven2Asset1Classifier,
            @RequestParam(value = "maven2.asset1.extension", required = false) String maven2Asset1Extension,
            @RequestParam(value = "maven2.asset2", required = false) MultipartFile maven2Asset2,
            @RequestParam(value = "maven2.asset2.classifier", required = false) String maven2Asset2Classifier,
            @RequestParam(value = "maven2.asset2.extension", required = false) String maven2Asset2Extension,
            @RequestParam(value = "maven2.asset3", required = false) MultipartFile maven2Asset3,
            @RequestParam(value = "maven2.asset3.classifier", required = false) String maven2Asset3Classifier,
            @RequestParam(value = "maven2.asset3.extension", required = false) String maven2Asset3Extension
    );

    /**
     * 得到一个组件信息
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/v1/components/{id}", produces = "application/json;charset=utf-8")
    ApiResponseXO<GetComponentResponse> getComponent(@PathVariable("id") String id);

    /**
     * 删除一个组件
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/v1/components/{id}", produces = "application/json;charset=utf-8")
    ApiResponseXO<Void> deleteComponent(@PathVariable("id") String id);

}
